from idlelib.debugger_r import close_subprocess_debugger


class TemConverter:
    C = 'C'
    F = 'F'
    def __init__(self, tem:float,  unit):
        if unit == TemConverter.C:
            self.C = tem
        elif unit == TemConverter.F:
            self.F = tem
    def getC(self):
        self.C =  5 * (self.F - 32) / 9
        return self.C
    def getF(self):
        self.F = 9 * self.C /5 + 32
        return self.F
    def getK(self):
        return self.C + 273.15

# tem = TemConverter(2, TemConverter.C)
# print(tem.getK())
# print(tem.getF())
#
# tem2 = TemConverter(0,TemConverter.F)
# print(tem2.getC())
# print(tem2.getK())

class TemConverter2:
    def __init__(self, tem:float,  unit):
        self._C = None
        self._F = None
        self._K = None
        if unit == 'C':
            self._C = tem
            self._F = TemConverter2.c2f(self._C)
            self._K = TemConverter2.c2k(self._C)

        elif unit == 'F':
            self._F = tem
            self._C = TemConverter2.f2c(self._F)
            self._K = TemConverter2.f2k(self._F)
        elif unit == 'K':
            self._K = tem
            self._F = TemConverter2.k2f(self._K)
            self._C = TemConverter2.k2c(self._K)

    @property
    def C(self):
        return self._C

    @property
    def F(self):
        return self._F

    @property
    def K(self):
        return self._K

    @classmethod
    def c2f(cls, c):
        f = 9 * c / 5 + 32
        return f

    @classmethod
    def f2c(cls, f):
        c = 5 * (f - 32) / 9
        return c

    @classmethod
    def c2k(cls, c):
        k = c + 273.15
        return k

    @classmethod
    def k2c(cls, k):
        c = k - 273.15
        return c

    @classmethod
    def f2k(cls, f):
        k = cls.c2k(cls.f2c(f))
        return k

    @classmethod
    def k2f(cls, f):
        f = cls.c2f(cls.k2c(f))
        return f

tem2 = TemConverter2(33,'K')
print(tem2.C, tem2.K, tem2.F)
print(TemConverter2.c2k(33))